package com.rpc;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class Provider {

    private static final ExecutorService executorService = Executors.newSingleThreadExecutor();

    public static void main1(String[] args) {
        UserService userServiceImpl = new UserServiceImpl();
        System.out.println(userServiceImpl.getClass().getName());
    }


    public static void main(String[] args) {

        UserService userServiceImpl = new UserServiceImpl();
        Register.register(UserService.class.getName(), userServiceImpl);
        try {
            ServerSocket serverSocket = new ServerSocket(8800);
            while (true){
               final Socket socket =  serverSocket.accept();
                executorService.execute(new SocketHandler((socket)));
            }
        } catch (IOException e) {
            e.printStackTrace();
        }

    }


}
